<?php
class searchService extends commonService{
	public function __construct(){
		parent::__construct();
		$this->table_arc=table('arc');
		
		$this->table_attr=table('attrtaglist');
		
		$this->table_word=table('wordtaglist');
	}
	
	public function search(){
	
	}
	//按标题搜索
	public function mylist_title($condition=array(),$extra=''){
        $return=array();
		$extra.=" and `title` like '%{$condition['_kw']}%' ";
		$extra.=" and `status`='1' ";
        $query="select `id`,`title`,`level_id`,`add_time`,`hits`,`htmlurl` from `{$this->table_arc}` where 1 {$extra} order by `id` desc";
        $p=new smart_pager($query,$this->m);
		foreach($condition as $k=>$v){
			$p->address("&{$k}=%{$k}%",$k,$v);
		}
        if($p->total_num>0){
            $return[]=$this->m->mselect($p->query);
            $return[]=$p;
        }
        return $return;
    }
	//按属性搜索
	public function mylist_attr($condition=array(),$extra=''){
		$return=array();
		$extra.=" and `t`.`tag` like '%{$condition['_kw']}%' ";
		$extra.=" and `a`.`status`='1' ";
        $query="select `a`.`id`,`a`.`title`,`a`.`level_id`,`a`.`add_time`,`a`.`hits`,`a`.`htmlurl` from `{$this->table_attr}` `t` left join `{$this->table_arc}` `a` on `t`.`arc_id`=`a`.`id` where 1 {$extra} order by `a`.`id` desc";
        $p=new smart_pager($query,$this->m);
		foreach($condition as $k=>$v){
			$p->address("&{$k}=%{$k}%",$k,$v);
		}
        if($p->total_num>0){
            $return[]=$this->m->mselect($p->query);
            $return[]=$p;
        }
        return $return;
	}
	//按单词搜索
	public function mylist_word($condition=array(),$extra=''){
		$return=array();
		$extra.=" and `t`.`tag` like '%{$condition['_kw']}%' ";
		$extra.=" and `a`.`status`='1' ";
        $query="select `a`.`id`,`a`.`title`,`a`.`level_id`,`a`.`add_time`,`a`.`hits`,`a`.`htmlurl` from `{$this->table_word}` `t` left join `{$this->table_arc}` `a` on `t`.`arc_id`=`a`.`id` where 1 {$extra} order by `a`.`id` desc";
        $p=new smart_pager($query,$this->m);
		foreach($condition as $k=>$v){
			$p->address("&{$k}=%{$k}%",$k,$v);
		}
        if($p->total_num>0){
            $return[]=$this->m->mselect($p->query);
            $return[]=$p;
        }
        return $return;
	}
//
}